#include<cstdio>
#include<algorithm>

using namespace std;

int main()
{
	long long n,sum=0;
	scanf("%lld",&n);
	if(n%2==0) sum=n/2;
	else{
		for(long long i=3;i*i<=n;i+=2){
			if(n%i==0){
				n-=i;
				sum++;
				break;
			}
		}
		if(n%2==0) sum=n/2;
		else sum=1;
	}
	printf("%lld",sum);
	return 0;
}
